﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace ST.Buz.Base.Migrations
{
    public partial class _2 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "PrinterName",
                table: "Sys_User");

            migrationBuilder.CreateTable(
                name: "BJG_Machining",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    SNo = table.Column<string>(unicode: false, maxLength: 32, nullable: true),
                    MachiningType = table.Column<int>(nullable: false),
                    PartnerID = table.Column<int>(nullable: false),
                    PartnerName = table.Column<string>(maxLength: 120, nullable: true),
                    DeliveryDate = table.Column<DateTime>(nullable: false),
                    DeliveryMan = table.Column<string>(maxLength: 20, nullable: true),
                    DeliveryPhone = table.Column<string>(maxLength: 30, nullable: true),
                    Rolls = table.Column<decimal>(type: "decimal(18,2)", nullable: false, defaultValueSql: "((0))"),
                    Meters = table.Column<decimal>(type: "decimal(18,2)", nullable: false, defaultValueSql: "((0))"),
                    Price = table.Column<decimal>(type: "decimal(18,2)", nullable: false, defaultValueSql: "((0))"),
                    Total = table.Column<decimal>(type: "decimal(18,2)", nullable: false, defaultValueSql: "((0))"),
                    StateNow = table.Column<int>(nullable: false),
                    RecvType = table.Column<int>(nullable: false),
                    RecvWay = table.Column<int>(nullable: false),
                    PreRecvTotal = table.Column<decimal>(type: "decimal(18,2)", nullable: false, defaultValueSql: "((0))"),
                    RecvState = table.Column<int>(nullable: false),
                    Comment = table.Column<string>(maxLength: 100, nullable: true),
                    AddDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    AddManID = table.Column<int>(nullable: false),
                    AddManName = table.Column<string>(maxLength: 20, nullable: true),
                    OrgID = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_BJG_Machining", x => x.ID)
                        .Annotation("SqlServer:Clustered", false);
                });

            migrationBuilder.CreateTable(
                name: "IMS_FinanceRecv",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    SNo = table.Column<string>(unicode: false, maxLength: 32, nullable: true),
                    ShareType = table.Column<int>(nullable: false, defaultValueSql: "((1))"),
                    PartnerID = table.Column<int>(nullable: false),
                    PartnerName = table.Column<string>(maxLength: 120, nullable: true),
                    RecvDate = table.Column<DateTime>(nullable: false),
                    RecvWay = table.Column<int>(nullable: false),
                    BillNo = table.Column<string>(maxLength: 30, nullable: true),
                    Invoice = table.Column<bool>(nullable: false),
                    InvoiceNo = table.Column<string>(maxLength: 20, nullable: true),
                    TotalRecv = table.Column<decimal>(type: "decimal(18,2)", nullable: false, defaultValueSql: "((0))"),
                    StateNow = table.Column<int>(nullable: false),
                    Comment = table.Column<string>(maxLength: 100, nullable: true),
                    AddDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    AddManID = table.Column<int>(nullable: false),
                    AddManName = table.Column<string>(maxLength: 20, nullable: true),
                    OrgID = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_IMS_FinanceRecv", x => x.ID)
                        .Annotation("SqlServer:Clustered", false);
                });

            migrationBuilder.CreateTable(
                name: "IMS_FinanceRecvDetail",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    RecvID = table.Column<int>(nullable: false),
                    DueID = table.Column<int>(nullable: false),
                    DueSNo = table.Column<string>(maxLength: 32, nullable: true),
                    Recved = table.Column<decimal>(type: "decimal(18,2)", nullable: false, defaultValueSql: "((0))"),
                    DetailAddDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    OrgID = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_IMS_FinanceRecvDetail", x => x.ID)
                        .Annotation("SqlServer:Clustered", false);
                });

            migrationBuilder.CreateTable(
                name: "IMS_FinanceRecvDue",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    SNo = table.Column<string>(unicode: false, maxLength: 32, nullable: true),
                    Stage = table.Column<string>(maxLength: 20, nullable: true),
                    DueDate = table.Column<DateTime>(nullable: true),
                    BuzType = table.Column<int>(nullable: false),
                    BuzID = table.Column<int>(nullable: false),
                    BuzSNo = table.Column<string>(maxLength: 32, nullable: true),
                    PartnerID = table.Column<int>(nullable: false),
                    PartnerName = table.Column<string>(maxLength: 120, nullable: true),
                    TotalRecvDue = table.Column<decimal>(type: "decimal(18,2)", nullable: false, defaultValueSql: "((0))"),
                    TotalRecved = table.Column<decimal>(type: "decimal(18,2)", nullable: false, defaultValueSql: "((0))"),
                    Invoice = table.Column<bool>(nullable: false),
                    Comment = table.Column<string>(maxLength: 100, nullable: true),
                    StateNow = table.Column<int>(nullable: false),
                    RecvState = table.Column<int>(nullable: false),
                    AddDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    AddManID = table.Column<int>(nullable: false),
                    AddManName = table.Column<string>(maxLength: 20, nullable: true),
                    OrgID = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_IMS_FinanceRecvDue", x => x.ID)
                        .Annotation("SqlServer:Clustered", false);
                });

            migrationBuilder.CreateIndex(
                name: "IX_BJG_Machining_PartnerID",
                table: "BJG_Machining",
                column: "PartnerID")
                .Annotation("SqlServer:Clustered", false);

            migrationBuilder.CreateIndex(
                name: "IX_IMS_FinanceRecv_PartnerID",
                table: "IMS_FinanceRecv",
                column: "PartnerID")
                .Annotation("SqlServer:Clustered", false);

            migrationBuilder.CreateIndex(
                name: "IX_IMS_FinanceRecvDetail_RecvID",
                table: "IMS_FinanceRecvDetail",
                column: "RecvID")
                .Annotation("SqlServer:Clustered", true);

            migrationBuilder.CreateIndex(
                name: "IX_IMS_FinanceRecvDue_PartnerID",
                table: "IMS_FinanceRecvDue",
                column: "PartnerID")
                .Annotation("SqlServer:Clustered", false);

            migrationBuilder.CreateIndex(
                name: "IX_IMS_FinanceRecvDue_BuzType_BuzID",
                table: "IMS_FinanceRecvDue",
                columns: new[] { "BuzType", "BuzID" })
                .Annotation("SqlServer:Clustered", false);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "BJG_Machining");

            migrationBuilder.DropTable(
                name: "IMS_FinanceRecv");

            migrationBuilder.DropTable(
                name: "IMS_FinanceRecvDetail");

            migrationBuilder.DropTable(
                name: "IMS_FinanceRecvDue");

            migrationBuilder.AddColumn<string>(
                name: "PrinterName",
                table: "Sys_User",
                type: "nvarchar(80)",
                maxLength: 80,
                nullable: true);
        }
    }
}
